#ifndef EVENTSERVE_H_
#define EVENTSERVE_H_
#include <ros/ros.h>
#include <cmath>
#include "trigger_response/event.h"
#include "trigger_response/action.hpp"
#include "nav_msgs/Odometry.h"
#include "std_msgs/Int32.h"
#include <mutex>


using namespace std;
class handle{
private:
    ros::NodeHandle nh_;
    ros::NodeHandle nh_private_;

    double Thd1_ = 5; // 小车感知范围的远近门限
    double Thd2_ = 5; // 小车与无人机的距离远近门限
    double Thd3_ = 5; // 小车距离目标点的远近门限
    ros::ServiceServer service_; // 
    ros::Subscriber list_service_sub;
    ros::Subscriber air_odom_sub;
    ros::Subscriber car_odom_sub;
    ros::Subscriber robot_odom_sub;

    std::vector<float> air_pose;
    std::vector<float> car_pose;
    Eigen::Vector3d robot_pose;
    std::mutex air_pose_mutex;
    std::mutex car_pose_mutex;
    std::mutex robot_pose_mutex;



    double AGDis_ = 0;
    double EGDis_ = 0;
    double TGDis_ = 0;
    int respose_;
    string Nodename_;

    std::shared_ptr<trigger_response_action> action_;

    int robotEType;
    float robot_x;
    float robot_y;
    float robot_z;

public:
    handle(const ros::NodeHandle &nh,const ros::NodeHandle &nh_private,const string& nodeName);
    bool ServiceCallback(trigger_response::event::Request &req,trigger_response::event::Response &res);
    void getRespose(string &eventCodeName,const short& smallType);
    void ListServiceCallback(const std_msgs::Int32::ConstPtr& msg);
    void odomCallback(const nav_msgs::Odometry::ConstPtr& msg);
    void robotCallback(const nav_msgs::Odometry::ConstPtr& msg);

};

#endif